﻿
@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<style type="text/css">
    .topPanel .search .input-group .form-control {
        padding: 4px 5px !important;
        height: 22px !important;
        margin: 0 10px !important;
        width: 80%;
    }

    .zdyPanel {
        height: 50px;
        line-height: 50px;
        background-color: #fff;
        border-top: 1px solid #ddd;
        border-left: 1px solid #ddd;
        border-right: 1px solid #ddd;
        margin: 0px;
        float: left;
        width: 100%;
    }

    .zdyTool {
        float: left;
        padding-left: 10px;
        width: 100%;
    }

    .zdyBar {
        height: 50px;
        line-height: 50px;
        padding: 0px;
        width: 100px;
        margin: 0px;
    }

    .trBj {
        background-color: #f5f5f5;
    }

    .trSelectBj {
        background-color: #fff6e5;
    }

    .MyMenu {
        width: 100px;
        height: 100px;
        background-color: #f5f5f5;
    }

    .zdyUL {
        list-style-type: none;
        margin: 0px;
        padding: 0px;
    }

        .zdyUL li {
            float: left;
            list-style: none;
            height: 20px;
            line-height: 20px;
        }

            .zdyUL li a {
                cursor: pointer;
                padding: 5px 10px;
                border-radius: 4px;
                color: #337ab7;
            }

            .zdyUL li i {
                margin-right: 4px;
                font-size: 13px;
                color: #666;
                vertical-align: middle;
                margin-top: -1px;
            }

            .zdyUL li a:hover {
                text-decoration: none;
                background-color: #1ABC9C;
                color: #fff;
            }

    .form-control {
        height: 20px;
        line-height: 20px;
        padding: 0px;
        border-radius: 2px;
    }

    .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {
        padding: 3px;
    }
</style>
<script>        
    $(function () {
        var F_OrderId = $.request("F_OrderId");
        loadData(F_OrderId);
    });

    function Dics(type, value) {
        if (type == "feetype") {
            if (value == "1") {
                return "场地费";
            }
            else if (value == "2") {
                return "搭建费";
            } else if (value == "3") {
                return "安保费";
            } else if (value == "4") {
                return "保洁费";
            } else if (value == "5") {
                return "宽带费";
            } else if (value == "6") {
                return "空调费";
            } else if (value == "7") {
                return "撤场";
            } else if (value == "8") {
                return "电费";
            } else if (value == "9") {
                return "消防";
            } else if (value == "10") {
                return "餐饮费";
            } else if (value == "11") {
                return "加班费";
            } else if (value == "12") {
                return "协助申办服务费";
            }
        } else if (type == "unit") {
            if (value == "1") {
                return "元/天";
            }
            else if (value == "2") {
                return "元/周";
            } else if (value == "3") {
                return "元/月";
            } else if (value == "4") {
                return "元/半天";
            } else if (value == "5") {
                return "元/小时";
            } else if (value == "6") {
                return "㎡/天";
            } else if (value == "7") {
                return "元/场";
            } else if (value == "8") {
                return "元/人";
            } else if (value == "9") {
                return "元/度(电)";
            } else if (value == "10") {
                return "元/m³(水)";
            } else if (value == "11") {
                return "元/个";
            }
        }
    }

    function loadData(F_OrderId) {
        $.ajax({
            url: "/CheckManager/CheckInfos/GetOrderPriceView?F_OrderId=" + F_OrderId + "",
            dataType: "json",
            async: false,
            success: function (data) {
                if (data != null && data.length>0) {
                    $("#F_ActivityTheme").html(data[0]["F_ActivityName"]);
                    $("#F_ActivityCityId").html(data[0]["F_ActivityCity"]);
                    var fid = "";
                    var count = 0;
                    for (var i = 0; i < data.length; i++) {
                        var nrow = "<tr>";
                        if (i == 0) {
                            fid = data[i]["spaceId"];
                            nrow += "<td>" + data[i]["SiteName"] + "</td>";
                            nrow += "<td>" + data[i]["SpaceName"] + "</td>";
                            nrow += "<td>" + data[i]["F_ActivityDate"] + "</td>";

                            nrow += "<td>" + Dics("feetype", data[i]["F_FeeType"]) + "</td>";
                            nrow += "<td>" + Dics("unit", data[i]["F_Unit"]) + "</td>";
                            nrow += "<td>" + data[i]["F_MarketPrice"] + "</td>";

                            nrow += "<td>" + data[i]["F_YunPrice"] + "</td>";
                            var F_SpaceArea = data[i]["F_SpaceArea"] == null ? "" : data[i]["F_SpaceArea"];
                            nrow += "<td>" + F_SpaceArea + "</td>";
                            nrow += "<td>" + data[i]["F_Quantity"] + "</td>";
                            nrow += "<td>" + data[i]["F_TotalPrice"] + "</td>";
                        } else {
                            if (fid == data[i]["spaceId"]) {
                                nrow += "<td></td>";
                                nrow += "<td></td>";
                                nrow += "<td></td>";

                                nrow += "<td>" + Dics("feetype", data[i]["F_FeeType"]) + "</td>";
                                nrow += "<td>" + Dics("unit", data[i]["F_Unit"]) + "</td>";
                                nrow += "<td>" + data[i]["F_MarketPrice"] + "</td>";

                                nrow += "<td>" + data[i]["F_YunPrice"] + "</td>";
                                var F_SpaceArea = data[i]["F_SpaceArea"] == null ? "" : data[i]["F_SpaceArea"];
                                nrow += "<td>" + F_SpaceArea + "</td>";
                                nrow += "<td>" + data[i]["F_Quantity"] + "</td>";
                                nrow += "<td>" + data[i]["F_TotalPrice"] + "</td>";
                            } else {
                                fid = data[i]["spaceId"];
                                nrow += "<td>" + data[i]["SiteName"] + "</td>";
                                nrow += "<td>" + data[i]["SpaceName"] + "</td>";
                                nrow += "<td>" + data[i]["F_ActivityDate"] + "</td>";

                                nrow += "<td>" + Dics("feetype", data[i]["F_FeeType"]) + "</td>";
                                nrow += "<td>" + Dics("unit", data[i]["F_Unit"]) + "</td>";
                                nrow += "<td>" + data[i]["F_MarketPrice"] + "</td>";

                                nrow += "<td>" + data[i]["F_YunPrice"] + "</td>";
                                var F_SpaceArea = data[i]["F_SpaceArea"] == null ? "" : data[i]["F_SpaceArea"];
                                nrow += "<td>" + F_SpaceArea + "</td>";
                                nrow += "<td>" + data[i]["F_Quantity"] + "</td>";
                                nrow += "<td>" + data[i]["F_TotalPrice"] + "</td>";
                            }
                        }
                        nrow += "</tr>";
                        count = count + parseFloat(data[i]["F_TotalPrice"]);
                        $("#newTable").append(nrow);
                    }
                    $("#sp_totalPrice").html(count.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'));
                }
            }, error: function (XMLHttpRequest, textStatus, errorThrown) {

            }
        });
    }

    function submitForm() {
        var opts = { btn: ['是', '否'] };
        $.modalConfirm('您确定发送报价单吗？', function (flag, index) {
            if (flag) {
                var F_CheckId = $.request("F_CheckId");
                var F_CheckUserId = $.request("F_CheckUserId");
                var ApplyType = $.request("ApplyType");
                var F_FlowId = $.request("F_FlowId");
                $.submitForm({
                    url: "/CheckManager/CheckInfos/CheckOrderPrice?orderPriceId=" + F_CheckId +"&F_CheckId=" + F_CheckId + "&F_State=1&F_CheckUserId=" + F_CheckUserId + "&ApplyType=" + ApplyType + "&F_FlowId=" + F_FlowId +"",
                    success: function () {
                        $.currentWindow().$("#gridList").trigger("reloadGrid");
                    },
                    close: true
                });   
            }
        }, opts);
        
    }
</script>
<form>
    <div style="padding-top: 5px;">
        <table class="form ui-jqgrid-htable ui-common-table table table-bordered">
            <tr class="ui-jqgrid-labels">
                <td class="formTitle">活动名称</td>
                <td><span id="F_ActivityTheme"></span></td>
            </tr>
            <tr class="ui-jqgrid-labels">
                <td class="formTitle">活动城市</td>
                <td><span id="F_ActivityCityId"></span></td>
            </tr>
        </table>
        <table class="form ui-jqgrid-htable ui-common-table table table-bordered" id="newTable">
            <thead>
                <tr class="ui-jqgrid-labels">
                    <th class="ui-th-column ui-th-ltr">场地名称</th>
                    <th class="ui-th-column ui-th-ltr">使用空间</th>
                    <th class="ui-th-column ui-th-ltr">活动档期</th>
                    <th class="ui-th-column ui-th-ltr" style="width:80px;">费用类品</th>
                    <th class="ui-th-column ui-th-ltr" style="width:60px;">单位</th>
                    <th class="ui-th-column ui-th-ltr" style="width:100px;">市场刊例价(元)</th>
                    <th class="ui-th-column ui-th-ltr" style="width:100px;">YUNSPACE价(元)</th>
                    <th class="ui-th-column ui-th-ltr" style="width:80px;">使用面积(㎡)</th>
                    <th class="ui-th-column ui-th-ltr" style="width:40px;">数量</th>
                    <th class="ui-th-column ui-th-ltr" style="width:80px;">合计价格(元)</th>                    
                </tr>
            </thead>
            <tbody></tbody>
            <tfoot>
                <tr>
                    <td colspan="9"><span style="float:right;font-weight:bold;">合计优惠价</span></td>
                    <td><span id="sp_totalPrice" style="color:#f0ad4e;"></span></td>
                </tr>
            </tfoot>
        </table>
    </div>
</form>

